package buco.http;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpSession;

import buco.core.api.CompositionContext;

public class CompositionServlet extends HttpServlet {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final String compositionSessionKey = "CompositionContext";

	protected CompositionContext getOrCreateComposition(HttpSession session) throws IOException {
		Object objCtx = session.getAttribute(compositionSessionKey);
		CompositionContext context = null; 
		
		if(objCtx == null) {
			context = new CompositionContext();  
			session.setAttribute(compositionSessionKey, context); 			
		}
		else {
			context = (CompositionContext) objCtx; 
		}
		
		return context; 		
	}
}
